﻿using B.S.Database.Domain.Entity;
using B.S.Database.ErrorCode;
using B.S.Database.Interface.Interface;
using B.S.Database.Read.Api.Application.Commands.Processing;
using MediatR;

namespace B.S.Database.Read.Api.Application.CommandHandler.Processing
{
    public class ProcessingShowCommandHandler : IRequestHandler<ProcessingShowCommands, Apiresult<List<Processing_Infomation>>>
    {
        private readonly IBaseResotity<Processing_Infomation> processingRepo;

        public ProcessingShowCommandHandler(IBaseResotity<Processing_Infomation> ProcessingRepo)
        {
            processingRepo = ProcessingRepo;
        }
        public Task<Apiresult<List<Processing_Infomation>>> Handle(ProcessingShowCommands request, CancellationToken cancellationToken)
        {
            Apiresult<List<Processing_Infomation>> res = new Apiresult<List<Processing_Infomation>>();
            res.Code = ApiEnums.成功;
            res.Message = ApiEnums.成功.ToString();
            var list = processingRepo.GetAll().Where(c => c.TraceabilityId == request.TraceabilityId);
            res.Data = list.ToList();
            return Task.FromResult(res);
        }
    }
}
